package cwb1;

import com.google.appengine.api.datastore.EntityNotFoundException;

/**
 * 
 * @author Aurora
 *
 */
public class AchievementManager {
	public final static long MAXIMISE = 1;
	public final static long MINIMISE = 0;
	
	private static AchievementManager instance = new AchievementManager();
	
    private AchievementManager() {
	
    }

    public static AchievementManager getAchievementManager() {
    	return instance;
    }
    
    public void update(User user) throws EntityNotFoundException {
		for(Achievement lusAchievement : AchievementRegistry.getInstance().getActiveAchievements()) {
			if(false) {
				user.addAchievement(lusAchievement);
				lusAchievement.addUser(user);
				//gegevens worden in de database gestoken.
				AchievementRegistry.getInstance().update(lusAchievement);
				UserRegistry.getInstance().update(user);
			}
	
		}
	}
	
    
	
	private boolean optionReached(Achievement achievement, long amount) {
		boolean reached = false;
		if(achievement.getOption() == MAXIMISE) {
			if(amount >= achievement.getAmountToReach()) {
				reached = true;
			}
		}
		else if(achievement.getOption() == MINIMISE) {
			if(amount <= achievement.getAmountToReach()) {
				reached = true;
			}
		}
		
		return true;
	}
}
